var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("UIConfig"),
    s = t("UIManager"),
    c = t("GameEm"),
    p = cc._decorator,
    l = p.ccclass,
    d = p.property,
    u =
        (p.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.viewNode = null;
                e.unlock = null;
                e.coin = null;
                e.lockcoin = null;
                e.lvLab = null;
                e.detailLab = null;
                e.upLv1Lab = null;
                e.upLv2Lab = null;
                e.btnNode = null;
                e.btnLab = null;
                e.itemData = null;
                e.indexKey = "";
                e.skillItemKey = {1: "995001", 2: "995002"};
                return e;
            }
            e.prototype.getSkillIndexKey = function () {
                return this.skillItemKey[this.indexKey];
            };
            e.prototype.setRewardKind = function (t, e) {
                if (t) {
                    this.itemData = t;
                    this.indexKey = e;
                    var o = GameDataValue.getBuyLockLv(),
                        a = GameDataValue.getBuySkillLv(e),
                        i = this.getLvData(t, a);
                    if (i) {
                        if (i.upgrade_type > o && 0 == a) {
                            this.viewNode.active = !1;
                            this.unlock.active = !0;
                            i.upgrade_type > o + 1 ? (this.btnNode.active = !1) : (this.btnNode.active = !0);
                        } else {
                            this.unlock.active = !1;
                            this.viewNode.active = !0;
                            a >= t.length - 1 ? (this.btnNode.active = !1) : (this.btnNode.active = !0);
                            this.lvLab.string = "level:" + a;
                            this.detailLab.string = this.getDetailLab(CacheDataManager.getLang(i.name), i.value1 + "%");
                            this.upLv1Lab.string = i.value1 + "%>";
                            var n = this.getLvData(t, a + 1);
                            this.upLv2Lab.string = n ? n.value1 + "%" : "";
                        }
                        SpriteView.setTaskSprite(this.coin, i.icon);
                        SpriteView.setTaskSprite(this.lockcoin, i.icon);
                        var r = i.up_cost || 0,
                            s = r + "";
                        this.btnLab.string = "-1" == s ? "满级" : "" + r;
                        var p = GameDataValue.getPropCount(c.PropKind.zhuanshi);
                        this.setBtnRender(p >= r);
                    }
                }
            };
            e.prototype.getDetailLab = function (t, e) {
                return "<color=#CF9B93>" + t + "</c><color=#824B51>" + e + "</c>";
            };
            e.prototype.getLvData = function (t, e) {
                for (var o in t) if (t[o].level == e) return t[o];
                return t[t.length - 1];
            };
            e.prototype.clickItem = function () {
                if (this.itemData) {
                    var t = GameDataValue.getPropCount(c.PropKind.zhuanshi),
                        e = GameDataValue.getBuySkillLv(this.indexKey),
                        o = this.getLvData(this.itemData, e).up_cost || 0;
                    if (t >= o) {
                        var a = {
                            resId: this.getSkillIndexKey(this.indexKey),
                            count: o,
                            type: 1,
                            tip: "游戏技能",
                            tip2: "第" + this.indexKey + "个"
                        };
                        GameDataValue.setPropCount(c.PropKind.zhuanshi, t - o);
                        0 == e && GameDataValue.addBuyLockLv();
                        var i = GameDataValue.getBuySkillLv(this.indexKey) + 1;
                        GameDataValue.setBuySkillLv(this.indexKey, i);
                        PayData.addLog(a.resId, a.count, a.type, [{id: 4, num: o}], a.tip, a.tip2);
                        this.scheduleOnce(function () {
                            EVUIEffView.emit(EVUIEffView.updateBtn);
                        });
                    } else s.default.open(r.UIID.UIToast, {msg: "钻石不足"});
                }
            };
            e.prototype.setBtnRender = function (t) {
                for (var e = this.btnNode.getComponentsInChildren(cc.RenderComponent), o = 0; o < e.length; o++)
                    CacheDataManager.setSpriteMat(e[o], t);
            };
            n([d(cc.Node)], e.prototype, "viewNode", void 0);
            n([d(cc.Node)], e.prototype, "unlock", void 0);
            n([d(cc.Sprite)], e.prototype, "coin", void 0);
            n([d(cc.Sprite)], e.prototype, "lockcoin", void 0);
            n([d(cc.Label)], e.prototype, "lvLab", void 0);
            n([d(cc.RichText)], e.prototype, "detailLab", void 0);
            n([d(cc.Label)], e.prototype, "upLv1Lab", void 0);
            n([d(cc.Label)], e.prototype, "upLv2Lab", void 0);
            n([d(cc.Node)], e.prototype, "btnNode", void 0);
            n([d(cc.Label)], e.prototype, "btnLab", void 0);
            return n([l], e);
        })(cc.Component));
o.default = u;
